/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_wtc_mar_get_boolean.c                           */
/*  NOTE      =                                                    */
/*  DATE      = 2016/02/24 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"

#include "../../../src/module/tuxedowtc/config.h"
#include <tuxedowtc/wtc_tpexception.h>
#include <tuxedowtc/wtc_comm.h>

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

/**
 * 正常测试
 */
static void __case1(void)
{
    char *p_error_msg = NULL;
    wtc_tpexception_format(0, 0, 0, &p_error_msg);
    CU_ASSERT_STRING_EQUAL(p_error_msg, "TPMINVAL(0):0:TPED_MINVAL(0)");
    wtc_free((void **) &p_error_msg);
}

/**
 * 异常测试
 */
static void __case2(void)
{
    char *p_error_msg = NULL;
    wtc_tpexception_format(1024, 0, 1024, &p_error_msg);
    CU_ASSERT_STRING_EQUAL(p_error_msg, "Unknown(1024):0:Unknown(1024)");
    wtc_free((void **) &p_error_msg);
}

int add_suite_wtc_tpexception_format(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" wtc_tpexception_format()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
